import {
  mapGetters
} from "vuex"

export default {
  computed: {
    ...mapGetters('m_cart', ['total'])
  },
  watch:{
    total(){
      this.setBadge()
    }
  },
  onShow() {
    this.setBadge()
  },
  methods: {
    setBadge() {
      // 为购物车设置右上角的徽标
      uni.setTabBarBadge({
        index: 2, //索引
        text: this.total + '' //text的值必须是字符串
      })
    }
  }

}
